package zhongbo.java.air.monitor.web.controller;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;
import zhongbo.java.air.monitor.model.FlightActivityDaily;
import zhongbo.java.air.monitor.service.IFlightActivityDailyService;

import java.util.List;

/**
 * @ClassName FlightActivityDailyController
 * @Description TODO
 * @Author 琪
 * @Date 2025/4/10 10:36
 */
@RestController
@RequestMapping("flightActivityDaily")
@Api(tags = "每日航迹活动信息接口")
public class FlightActivityDailyController {

    @Autowired
    private IFlightActivityDailyService flightActivityDailyService;

    @ApiOperation("查询当天航迹活动结果")
    @GetMapping("getDailyStats")
    public ResultVo<List<FlightActivityDaily>> getDailyStats(String date) {
        // 如果不传, 则默认查当天的统计结果
        if (StrUtil.isBlank(date)) {
            date = DateUtil.today();
        }
        List<FlightActivityDaily> dailyList = flightActivityDailyService.getDailyStats(date);
        return ResultVo.ok(dailyList);
    }

    // to//do 今日周二待做, 标准crud接口(包括分页)

    @PostMapping("add")
    @ApiOperation("添加")
    ResultVo<FlightActivityDaily> add(@RequestBody FlightActivityDaily entity) {
        FlightActivityDaily flightActivityDaily = flightActivityDailyService.add(entity);
        return ResultVo.ok(flightActivityDaily);
    }

    @GetMapping("delete")
    @ApiOperation("删除")
    ResultVo<String> delete(String entityId) {
        String delete = flightActivityDailyService.delete(entityId);
        return ResultVo.ok(delete);
    }

    @PostMapping("edit")
    @ApiOperation("修改")
    ResultVo<FlightActivityDaily> edit(@RequestBody FlightActivityDaily edit) {
        FlightActivityDaily flightActivityDaily = flightActivityDailyService.edit(edit);
        return ResultVo.ok(flightActivityDaily);
    }

    @GetMapping("findOne")
    @ApiOperation("查询一条")
    ResultVo<FlightActivityDaily> findOne(String entityId) {
        FlightActivityDaily flightActivityDaily = flightActivityDailyService.findOne(entityId);
        return ResultVo.ok(flightActivityDaily);
    }

    @GetMapping("findPage")
    @ApiOperation("分页查询列表")
    ResultVo<PageVo<FlightActivityDaily>> findPage(Integer page, Integer pageSize
            , String icao, String startDate, String endDate
            , String keyword, String fields
            , String oderByField, Boolean orderByAsc) {
        PageVo<FlightActivityDaily> pageVo = flightActivityDailyService.findPage(
                icao, startDate, endDate,
                 keyword, fields,page, pageSize, oderByField, orderByAsc);
        return ResultVo.ok(pageVo);
    }

}
